package jm.coll.map;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @Description Map接口常用方法
 * @date 2022/4/3 14:10
 */
public class MapMethods {
    public static void main(String[] args) {
        HashMap<String ,String > map = new HashMap<>();
        String put = map.put("a", "b");
        map.put("a","x");
        map.put("d","x");
        map.put("e","x");
        map.put("f","x");


        String a = map.remove("a");

        map.isEmpty();

        map.clear();

        map.containsKey("a");

        // 返回entrySet，里面为k-v键值对
        for (Map.Entry<String, String> entry : map.entrySet()) {
            System.out.println(entry);
        }

        // 遍历key
        for (String s : map.keySet()) {
            System.out.println(s);
            System.out.println(map.get(s));
        }

        // 遍历value
        for (String value : map.values()) {
            System.out.println(value);
        }

    }
}
